package com.czy.owner.api;

import android.text.TextUtils;

import com.czy.owner.db.UserHelper;
import com.czy.owner.global.Constants;
import com.czy.owner.net.api.BaseApi;
import com.czy.owner.net.listener.HttpOnNextListener;
import com.trello.rxlifecycle.components.support.RxAppCompatActivity;

import java.util.HashMap;

import retrofit2.Retrofit;
import rx.Observable;

/**
 * Created by asus on 2017/6/6.
 */

public class SelectStoreApi extends BaseApi {
    private String session;
    private String gprsX;
    private String gprsY;
    private String goodsId;
    private String page;
    private String size;
    private String name;
    private String type = "normal";

    public String getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(String goodsId) {
        this.goodsId = goodsId;
    }

    public String getPage() {
        return page;
    }

    public void setPage(String page) {
        this.page = page;
    }

    public String getSize() {
        return size;
    }

    public void setSize(String size) {
        this.size = size;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGprsX() {
        return gprsX;
    }

    public void setGprsX(String gprsX) {
        this.gprsX = gprsX;
    }

    public String getGprsY() {
        return gprsY;
    }

    public void setGprsY(String gprsY) {
        this.gprsY = gprsY;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public SelectStoreApi(HttpOnNextListener listener, RxAppCompatActivity rxAppCompatActivity) {
        super(listener, rxAppCompatActivity);
        setShowProgress(false);
        setCache(true);
        setCookieNetWorkTime(0);//有网缓存0s,在0s内点击无效
        setCookieNoNetWorkTime(0);
    }

    public String getSession() {
        return session;
    }

    public void setSession(String session) {
        this.session = session;
    }


    @Override
    public Observable getObservable(Retrofit retrofit) {
        HttpPostService service = retrofit.create(HttpPostService.class);
        HashMap<String, Object> map = new HashMap<>();
        map.put("session", getSession());
        map.put("gprsX", getGprsX());
        map.put("gprsY", getGprsY());
        map.put("page", getPage());
        map.put("size", getSize());
        map.put("goodsId", getGoodsId());
        map.put("type",type);
        if (!TextUtils.isEmpty(getName())) {
            map.put("name", getName());
        }
        return service.getInstallStore(map);
    }
}
